﻿using System;
using System.Xml;
using System.Xml.Serialization;
using SS4U.Library;

namespace SimpleSearch4Umbraco.TestConsole
{
// ReSharper disable ClassNeverInstantiated.Global
    class Program
// ReSharper restore ClassNeverInstantiated.Global
    {
        static void Main()
        {
            Console.WriteLine("Start...");

            var sr = new SearchResultCollection
                         {
                             new SearchResult
                                 {
                                     Category = "User 1",
                                     CreateDate = DateTime.Now,
                                     Id = 1,
                                     LinkUrl = "/test1",
                                     Text = "Text to see 1"
                                 },
                             new SearchResult
                                 {
                                     Category = "User 2",
                                     CreateDate = DateTime.Now,
                                     Id = 2,
                                     LinkUrl = "/test2",
                                     Text = "Text to see 2"
                                 },
                             new SearchResult
                                 {
                                     Category = "User 3",
                                     CreateDate = DateTime.Now,
                                     Id = 3,
                                     LinkUrl = "/test3",
                                     Text = "Text to see 3"
                                 },
                             new SearchResult
                                 {
                                     Category = "User 4",
                                     CreateDate = DateTime.Now,
                                     Id = 4,
                                     LinkUrl = "/test4",
                                     Text = "Text to see 4"
                                 }
                         };

            var ser = new XmlSerializer(typeof(SearchResultCollection));
            var xml = new XmlDocument();

            using (var ms = new System.IO.MemoryStream())
            {
                ser.Serialize(ms, sr);
                ms.Position = 0;
                xml.Load(ms);
                ms.Close();
            }
            xml.Save(@"C:\test.xml");

            Console.WriteLine("End...");
            Console.ReadKey();
        }
    }
}
